﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using Taxes.Model;
namespace Taxes.BLL
{
	/// <summary>
	/// 楼层折算率
	/// </summary>
	public partial class floor_convert
	{
		private readonly Taxes.DAL.floor_convert dal=new Taxes.DAL.floor_convert();
		public floor_convert()
		{}
		#region  Method

        public void MaxMinFloor(bool hasLift, out int max, out int min)
        {
             dal.MaxMinFloor(hasLift,out max,out min);
        }
		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int ID)
		{
			return dal.Exists(ID);
		}
        public bool ExistFloor(int floor,int lift)
        {
            return dal.ExistFloor(floor,lift);
        }
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(Taxes.Model.floor_convert model)
		{
			return dal.Add(model);
		}
        public Taxes.Model.floor_convert GetModelByFloorNumAndLift(int floorNumber, bool hasLift)
        {
            return dal.GetModelByFloorNumAndLift(floorNumber, hasLift);
        }

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Taxes.Model.floor_convert model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Taxes.Model.floor_convert GetModel(int ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public Taxes.Model.floor_convert GetModelByCache(int ID)
		{
			
			string CacheKey = "floor_convertModel-" + ID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (Taxes.Model.floor_convert)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Taxes.Model.floor_convert> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Taxes.Model.floor_convert> DataTableToList(DataTable dt)
		{
			List<Taxes.Model.floor_convert> modelList = new List<Taxes.Model.floor_convert>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Taxes.Model.floor_convert model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Taxes.Model.floor_convert();
					if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
					{
						model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
					}
					if(dt.Rows[n]["floor_num"]!=null && dt.Rows[n]["floor_num"].ToString()!="")
					{
						model.floor_num=int.Parse(dt.Rows[n]["floor_num"].ToString());
					}
					if(dt.Rows[n]["floor_elevator"]!=null && dt.Rows[n]["floor_elevator"].ToString()!="")
					{
						model.floor_elevator=int.Parse(dt.Rows[n]["floor_elevator"].ToString());
					}
					if(dt.Rows[n]["floor_converter"]!=null && dt.Rows[n]["floor_converter"].ToString()!="")
					{
						model.floor_converter=decimal.Parse(dt.Rows[n]["floor_converter"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

